package model.effect;

import model.entity.BasicEntity;
import utilities.*;

/**
 * An abstract class to define the interface for both type of stat changes, so they can be used interchangeably.
 */
abstract class ChangeStatEffect extends Effect implements Archiveable {

	private String statType;
	private int amountChanged;

	/* --------------------------------------------------------------------------------
	 * Constructors
	   -------------------------------------------------------------------------------- */
	
	/**
	 * @param name The name of this model
	 * @param statType The name of the Stat that will be modified by this effect
	 * @param amountChanged The change in the stat
	 */
	public ChangeStatEffect(String name, String statType, int amountChanged) {
		super(name);
		this.statType = statType;
		this.amountChanged = amountChanged;
	}

	public ChangeStatEffect() {}
	
	/* --------------------------------------------------------------------------------
	 * Getters and Setters
	   -------------------------------------------------------------------------------- */
	
	/**
	 * @return the Stat's name
	 */
	public String getStatType() {
		return statType;
	}

	/**
	 * @return the amount the stat is changed
	 */
	public int getAmountChanged() {
		return amountChanged;
	}

	/* --------------------------------------------------------------------------------
	 * Class methods
	   -------------------------------------------------------------------------------- */
	
	abstract public void doEffect(BasicEntity ent);

	@Override
	public String toString()
	{
		return super.toString() + "ChangeStatEffect [statType=" + statType + ", amountChanged=" + amountChanged + "]";
	}
		
	public Archive save() {
		Archive archive = super.save();
		
//		archive.putAttribute("amountChanged", Integer.toString(this.amountChanged));
//		archive.putAttribute("statType", this.statType);
		
		return archive;
	}
	
	public void load(Archive archive) {
		super.load(archive);
		
//		this.amountChanged = Integer.parseInt(archive.getAttribute("amountChanged"));
//		this.statType = archive.getAttribute("statType");
	}
	
}
